package text;

import com.chixing.day02.SortUtil;

public class SearchElements {
    public static void main(String[] args) {
        int[] arr1 = {10,20,30,40,30,50,60,70,10,70};
        for (int i = 0; i < arr1.length; i++) {
            int temp = 0;
            for (int j = 0; j < arr1.length; j++) {
                if(arr1[i]==arr1[j]){
                    temp++;
                }
            }
            if(temp == 1){
                System.out.println(arr1[i]);
            }
        }

        System.out.println("==========================");
        int[] nums = {-1,0,1,2,-1,-4};
        nums = SortUtil.buBboSort(nums);//-4,-1,-1,0,1,2
        String[] arr = new String[3];
        int count1 = 0;
        String str = "";
        for (int i = 0; i < nums.length; i++) {
            for (int j = i+1; j < nums.length; j++) {
                for (int k = j+1; k < nums.length; k++) {
                    if (nums[i] + nums[j] + nums[k] == 0) {
                        str = "["+nums[i]+","+nums[j]+","+nums[k]+"]";
                        arr[count1++] = str;
                    }
                }
            }
        }
        traverse(arr);
        System.out.println("==========================");
        String[] words = {"abcw","baz","foo","bar","fxyz","abcdef"};
        int temp = 0;
        for (int i = 0; i < words.length; i++) {
            for (int j = i+1; j < words.length; j++) {
                if(compare(words[i],words[j])==true){
                     if(words[i].length()*words[j].length()>temp)
                         temp = words[i].length()*words[j].length();
                }

            }
        }
        System.out.println(temp);

    }
    public static boolean compare(String str1,String str2){
        for (int i = 0; i < str1.length(); i++) {
            for (int j = 0; j < str2.length(); j++) {
                if(str1.charAt(i)==str2.charAt(j))
                    return true;
            }
        }
        return false;
    }
    public static void traverse(String[] arr){
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            int count = 0 ;
            for (int j = i+1; j<arr.length; j++) {
                if(arr[i].equals(arr[j]))
                    count++;
                }
            if (count==0){
                if(i== arr.length-1)
                    System.out.print(arr[i]);
                else
                    System.out.print(arr[i]+",");
            }
        }
        System.out.println("]");
    }
}
